package dev.alm.service.controller;

import dev.alm.service.common.Result;
import dev.alm.service.entity.User;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping("user")
@CrossOrigin
public class UserController {

    @GetMapping("list")
    public Result list() {
        ArrayList<User> users = new ArrayList<User>();
        for (int i = 1; i < 11; i++) {
            User user = new User();
            user.setId(i);
            user.setUsername("username " + i);
            user.setPassword("password " + i);
            user.setEmail("email " + i);
            users.add(user);
        }
        Result r = new Result();
        r.setCode(200);
        r.setMessage("success");
        r.setData(users);
        return r;
    }
}
